USE [QLDL]
GO

/****** Object:  UserDefinedFunction [dbo].[f_BaoCaoDoanhSo]    Script Date: 01/03/2011 15:33:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE function [dbo].[f_BaoCaoDoanhSo]
	(@Thang int, @Nam int)
returns @BangKetQua table
(	STT int identity(1, 1),
	DaiLy ntext,
	SoPhieuXuat int,
	TongTriGia money,
	TyLe float
)
as
begin
	insert into @BangKetQua select TenDaiLy, SoLuongPXH, TongTriGia, TyLe 
							from DAILY, DOANHSO
							where (DAILY.MaDaiLy = DOANHSO.MaDaiLy) 
							and (DOANHSO.Thang = @Thang) 
							and (DOANHSO.Nam = @Nam)
							order by CAST(TenDaiLy as nvarchar(200)) asc
	return
end
GO


